package com.redispro.config;

import com.redispro.interceptors.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.servlet.config.annotation.*;

/**
 * @Auther: 李 力
 * @Date: 2024/11/22
 * @Description: com.redispro.config
 * @version: 1.0
 */
@Configuration
public class MVCConfig implements WebMvcConfigurer {

    @Autowired
    private StringRedisTemplate redisTemplate;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor()).excludePathPatterns(
                "/shop/**",
                "/voucher/**",
                "/shop-type/**",
                "/blog/hot",
                "/user/code",
                "/user/login"
        ).order(1);

        registry.addInterceptor(new ReFreshInterceptor(redisTemplate)).addPathPatterns("/**").order(0);
    }
}
